<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件处理器-模态框(案例)</title>
    <script src="../vue2.js"></script>
    <style>
        /**{*/
        /*    margin: 0;*/
        /*    padding: 0;*/
        /*}*/
        #overlay {
            width: 100%;
            margin: auto;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(59, 59, 59, 0.5);
        }

        .box {
            width: 500px;
            height: 350px;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #ffffff;
            border-radius: 10px;
        }

        .box form {
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            flex-wrap: wrap;
            font-size: 25px;
        }

        .box form input {
            font-size: 25px;
            border-radius: 5px;
        }

        button {
            width: 300px;
            height: 30px;
            font-size: 20px;
            border-radius: 5px;
            outline: none;
        }

    </style>
</head>
<body>
<div id="body">
    <button @click="boxShow=true">请登录</button>

    <!--模态框-->
    <div id="overlay" v-show="boxShow" @click.self="boxShow=false">
        <div class="box" v-show="boxShow">
            <form action="" @click.prevent>   <!-- 事件修饰符prevent: 阻止默认行为 -->
                <label>用户名：
                    <input type="text">
                </label><br>
                <label>密&nbsp&nbsp&nbsp码：
                    <input type="password">
                </label><br>
                <button @click="boxShow=false">登录</button>
            </form>
        </div>
    </div>
</div>
<script>
    new Vue({
        el: '#body',
        data: {
            boxShow: false,
        }
    })
</script>
</body>
</html>